<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>逾期催收沟通记录表 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">催收方式</div>
                    <div class="field">
                        <input name="collectWayCd" id="collectWayCd" placeholder="请选择" ltype="combobox">
                    </div>
                </div>

                <div class="fieldBox">
                    <div class="label">催收时间</div>
                    <div class="field">
                        <input ligerui="width: 100" name="startCollectTm" id="startCollectTm" type="text" class="ui-datepicker" value="" >
                        -
                        <input ligerui="width: 100" name="endCollectTm" id="endCollectTm" type="text" class="ui-datepicker" value="">
                    </div>
                </div>

                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="addLMBtn" class="sq-button sq-button-round" onclick="toCustNpList('${cstId}','1');">新增联系人</span>
                    <span id="addRskBtn" class="sq-button sq-button-round" onclick="addRskBtn();">添加催收记录</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<!-- 添加催收记录弹出层 start-->
<div id="div_rsk_type" style="display:none">
    <form id="div_rsk_type_form">
        <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">

            <div class="fieldBox col_50">
                <div class="label" id="div_rsk_name_column_tip">客户名称</div>
                <div class="field">
                    <input name="winCstNm" id="winCstNm" type="text" class="ui-textbox"  value="${rskCommRecVO.cstNm}" readonly="readonly">
                    <span class="requiredSymbol"></span>
                </div>
                <input name="winCstId" id="winCstId" type="text" style="display: none;" value="${rskCommRecVO.cstId}" >
            </div>
            <div class="fieldBox col_50">
                <div class="label" id="div_rsk_paytypcd_column_tip">还款方式</div>
                <div class="field">
                    <%--<input name="winPayTypCd" id="winPayTypCd" type="text" class="ui-textbox" value="${rskCommRecVO.payTypCd}" readonly="readonly">--%>
                    <input name="winPayTypCd" id="winPayTypCd" data-value="${rskCommRecVO.payTypCd}" placeholder="请选择" ltype="combobox">
                    <span class="requiredSymbol"></span>
                </div>
            </div>

             <div class="fieldBox col_50">
                <div class="label">逾期金额(元)</div>
                <div class="field">
                    <input name="ovdAmt" id="ovdAmt" type="text" class="ui-textbox"  value="${ovdAmt}" readonly="readonly">
                    <span class="requiredSymbol"></span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label" >催收日期</div>
                <div class="field">
                    <input name="minOverdueDate" id="minOverdueDate" type="text" class="ui-textbox"   readonly="readonly">
                    <span class="requiredSymbol"></span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label" id="div_rsk_lkman_column_tip">联系人</div>
                <div class="field">
                    <input name="winlkMan" id="winlkMan" validate="{required:true}" type="text" class="ui-textbox" value="" placeholder="请选择"  onclick="toCustNpList('${cstId}','2');">
                    <span id="winlkManRl"></span>
                    <span class="requiredSymbol">*</span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label" id="div_rsk_lkphone_column_tip">联系电话</div>
                <div class="field">
                    <input name="winLkPhone" id="winLkPhone" validate="{required:true}" type="text" class="ui-textbox" value="" readonly="readonly">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>

            <div class="fieldBox col_50">
                <div class="label" id="div_rsk_lkaddr_column_tip">联系地址</div>
                <div class="field">
                    <input name="winLkAddr" id="winLkAddr" type="text" class="ui-textbox" value="" readonly="readonly" >
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label" >贷前风险标记</div>
                <div class="field">
                    <input name="preLoanRskInfo" id="preLoanRskInfo" validate="{required:true}" type="text" class="ui-textbox" value="${preLoanRskInfo }"  readonly="readonly">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>


            <div id="win_np_block_id" style="display:block">
                <div class="fieldBox col_100">
                    <div class="label">催收方式</div>
                    <div class="field" >
                        <div id="winCollectWayCd"></div>
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label" style="width: 155px">客户反馈受新型肺炎影响</div>
                    <div class="field">
                        <select name="cstFeedbackCd" id="cstFeedbackCd">
                            <c:forEach items="${cstFeedbackCdList}" var="cfb">
                                <option value="${cfb.key}">${cfb.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label" style="width: 155px">公司审批受新型肺炎影响</div>
                    <div class="field">
                        <select name="compFeedbackCd" id="compFeedbackCd">
                            <c:forEach items="${compFeedbackCdList}" var="cfb">
                                <option value="${cfb.key}">${cfb.value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>

                <div class="fieldBox col_100">
                    <div class="label">逾期原因</div>
                    <div class="field" >
                        <div id="winOvdReasonCd"></div>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">风险等级</div>
                    <div class="field">
                        <input type="text" id="winPayWnCd" name="winPayWnCd" ltype="combobox" validate="{required:true}" placeholder="请选择"/>
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>

                <div class="fieldBox col_50">
                    <div class="label">C卡结果</div>
                    <div class="field">
                        <select name="cCardRiskLevel" id="cCardRiskLevel">
                            <c:forEach items="${cRiskLevel}" var="cfb">
                                <option value="${cfb.key}">${cfb.value}</option>
                            </c:forEach>
                        </select>
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_50" style="margin-left: 143px;">
                    <div class="label">催收人员风险判定结果</div>
                    <select name="collectRiskLevel" id="collectRiskLevel">
                        <c:forEach items="${collectRiskLevel}" var="cfb">
                            <option value="${cfb.key}">${cfb.value}</option>
                        </c:forEach>
                    </select>
                    <span class="requiredSymbol">*</span>
                </div>

                <div class="fieldBox col_50" style="margin-left: 143px;">
                    <div class="label">风险判定差异原因</div>
                    <select name="levelDifRsn" id="levelDifRsn">
                        <option >请选择</option>
                        <option value="跳票">跳票</option>
                        <option value="已沟通风险可控">已沟通风险可控</option>
                    </select>
                    <span class="requiredSymbol">*</span>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">渠道参与</div>
                    <div class="field" >
                        <div id="participantDiv"></div>
                    </div>
                </div>
                <%--<div class="fieldBox col_100">--%>
                    <%--<div class="label">催收策略</div>--%>
                    <%--<div class="field">--%>
                        <%--<textarea name="winOvdRule" id="winOvdRule" rows="3" class="ui-textarea l-textarea" style="width:80%" value="" validate="{required:true}" readonly="readonly"></textarea>--%>
                        <%--<span class="requiredSymbol">*</span>--%>
                    <%--</div>--%>
                <%--</div>--%>



            </div>

            <div class="fieldBox col_50">
                <div class="label">催收员</div>
                <div class="field">
                    <input name="winCollectUsrNm" id="winCollectUsrNm" type="text" class="ui-textbox" value="${rskCommRecVO.collectUsrNm}" validate="{required:true}" readonly="readonly">
                    <span class="requiredSymbol">*</span>
                </div>
                <input name="winCollectUsrId" id="winCollectUsrId" type="text" style="display: none;" value="${rskCommRecVO.collectUsrId}" >
            </div>

            <!-- 信函相关DIV -->
            <div id="letterDiv" style="display: none">
                <div class="fieldBox col_100" id="winLetterTypCdDiv">
                    <div class="label">信函类型</div>
                    <div class="field" >
                        <div id="winLetterTypCd"></div>
                    </div>
                </div>
                <div class="fieldBox col_100" id="letterSendResDiv">
                    <div class="label">信函发送结果</div>
                    <div class="field" >
                        <div id="letterSendRes"></div>
                    </div>
                </div>
                <div class="fieldBox col_50" id="letterSendWayDiv">
                    <div class="label">信函发送方式</div>
                    <div class="field">
                        <div id="letterSendWay"></div>
                    </div>
                </div>
                <div class="fieldBox col_50" id="expressNoDiv" style="display: none">
                    <div class="label">快递单号</div>
                    <div class="field">
                        <input name="expressNo" id="expressNo" type="text" class="ui-textbox">
                    </div>
                </div>
            </div>

            <div class="fieldBox col_100" id="winCntStsCdDiv" style="display: none">
                <div class="label">接通状态</div>
                <div class="field" >
                    <div id="winCntStsCd"></div>
                </div>
            </div>
            <div class="fieldBox col_100" style="display: none" id="winCollectRstCdDiv">
                <div class="label">催收结果</div>
                <div class="field" >
                    <div id="winCollectRstCd"></div>
                </div>
            </div>


            <div id="winRlNmDiv" style="display: none">
                <div class="fieldBox col_50">
                    <div class="label">面谈人</div>
                    <div class="field">
                        <input name="winRlNm" id="winRlNm" type="text" class="ui-textbox" placeholder="请选择" onclick="toCustNpList('${cstId}','3');">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>

                <div class="fieldBox col_100"  >
                    <div class="label">外访结果</div>
                    <div class="field">
                        <div id="winVisitRstCd"></div>

                    </div>
                </div>
                <div class="fieldBox col_100"  >
                    <div class="label">地址真实性</div>
                    <div class="field">
                        <div id="isRealAdress"></div>

                    </div>
                </div>
                <div class="fieldBox col_100" style="display: none" id="realAdressDiv">
                    <div class="label">真实地址</div>
                    <div class="field">
                        <input name="realAdress" id="realAdress" type="text" class="ui-textbox">
                    </div>
                </div>
            </div>

        </div>

        <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
            <%--<div class="fieldBox col_100">
                <div class="label">上传附件</div>
                <div class="field">
                    <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true" >
                        <jsp:param name="filePath" value="capital/capPayInfo"/>
                    </jsp:include>
                    <input id="tabNm"  name="tabNm"  type="hidden"  value="PRJ_PRD_DTL">
                    <input  id="pkId"  name="pkId"  type="hidden"  value="${dtlId}">
                </div>
            </div>--%>

            <div class="fieldBox col_100">
                <div class="label">资料上传</div>
                <div class="field">
                    <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true" >
                        <jsp:param name="filePath" value="customer"/>
                    </jsp:include>
                </div>
            </div>

            <div class="fieldBox col_100">
                <div class="label">催收详情</div>
                <div class="field">
                    <textarea name="winCollectRem" id="winCollectRem" rows="6" class="ui-textarea l-textarea" style="width:80%" value="" validate="{required:true,maxlength:200}"></textarea>
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
        </div>
    </form>
</div>
<!-- 添加催收记录弹出层 end-->
<!-- 查看 催收记录弹出层 start-->
<!-- 查看 催收记录弹出层 end-->

<script type="text/javascript">
    var grid = null,form=null;
    $(function () {
        initFormData();//初始化弹出层form数据
        initGrid();//初始化列表
        eventRegiste();// 事件注册
        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

    });
    function reset(){
        liger.get("winOvdReasonCd").refresh();
        liger.get("participantDiv").refresh();
        liger.get("winLetterTypCd").refresh();
        liger.get("letterSendRes").refresh();
        liger.get("letterSendWay").refresh();
        liger.get("winCntStsCd").refresh();
        liger.get("winCollectRstCd").refresh();
        liger.get("winVisitRstCd").refresh();
        liger.get("isRealAdress").refresh();
        $("#realAdress").val("")
        $("#winRlNm").val("");
        $("#winRlMp").val("");
        $("#winRlTypCd").val("");
        $("#expressNo").val("")
        liger.get("winPayWnCd").setValue();
        $("#winCollectRem").val("")
        $("#winCntStsCdDiv").hide();
        $("#letterDiv").hide()
        $("#winRlNmDiv").hide()
        $("#winCollectRstCdDiv").hide()
    }
    // 清空页面
    function refresh(){
        reset()
        eventRegiste()
    }

    // 客户详情页面
    function showDetail(_id){
        parent.parent.mainApp.f_addTab('tab_customer_np_detail'+_id,'客户详情','<%=path%>/customer/cstbscinfo/showDetail.do?id='+_id);
        <%--parent.pageInTab.addTabItem({tabid:'tab_customer_np_detail'+_id,text:'客户详情',url:'<%=path%>/customer/cstbscinfo/showDetail.do?id='+_id});--%>
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
  //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    //初始化列表 start
    function initGrid(){
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/risknew/rskCommRecNew/initList.do?cstId=${cstId}&buTypCd=1',
            method: 'get',
            columns: [
                {display: '客户名称', name: 'cstNm', width: 60, align: 'left', enabledSort: false, render: function (rowdata, rowindex, value, column) {
                        if(StringUtils.isEmpty(value)){
                            value = "";
                        }
                        var h = '';
                        h='<a href="javascript:showDetail(';
                        h+="'"+rowdata.cstId+"'";
                        h+=')">'+value+'</a>'
                        return h;
                    }},
                {display: '催收时间', name: 'collectTm', width: 130, align: 'left', enabledSort: false, render: renderDate2},
                {display: '催收方式', name: 'collectWayCdNm', width: 80, align: 'center', enabledSort: false},
                {display: '催收员', name: 'collectUsrNm', width: 80, align: 'left', enabledSort: false},
                {display: '逾期原因', name: 'ovdReasonCdNm', width: 150, align: 'left', enabledSort: false},
                {display: '催收详情', name: 'collectRem', width: 380, align: 'left', enabledSort: false,
                	render:function(rowdata,index,value){
                        return '<span class="gridTip" style="cursor: pointer;" title="'+ rowdata.collectRem +'">'+rowdata.collectRem+'</span>';
                    }
                },
                {display: '贷前风险标记', name: 'preLoanRskInfo', width: 150, align: 'left', enabledSort: false},
                {display: '联系人', name: 'lkMan', width: 70, align: 'left', enabledSort: false},
                {display: '联系电话', name: 'lkPhone', width: 110, align: 'center', enabledSort: false},
                {display: '催收结果', name: 'collectRstCdNm', width: 120, align: 'center', enabledSort: false},
                { display: '操作', name: '',width:80,
                    render: function (rowdata, rowindex, value){
                        var v = '<a class="sq-button-hasicon" href="javascript:toViewPageInfo(';
                        v += "'" + rowdata.id + "'";
                        v += ')"><i class="sqBtnIco_4"></i>查看</a>';
                        return v;
                    }
                },
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            enabledEdit: true,
        });
        grid.setHeight(100);
        //还款方式
        $("#winPayTypCd").ligerComboBox({
            valueField: 'key',
            textField: 'value',
        });
        //催收方式
        $("#collectWayCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        form=$("#searchBar").ligerForm();
        liger.get("winPayTypCd").setData(${payTypCdList});
        liger.get("winPayTypCd").setDisabled();
        liger.get("collectWayCd").setData(${collectWayCdList});
        $("#pageloading").hide();
    }
    //初始化列表 end

    //添加催收记录弹出层 start
    var ligerRskForm;
    var cstTypCd; // 1:自然人  2：法人
    function addRskBtn(){
        refresh()
        $.ligerDialog.SQopen({
            width: 800,
            top: 100,
            buttons: [
                {
                    text: "保存", cls: 'l-dialog-btn-ok', onclick:function(){
                        doAdd();//执行保存
                    }
                }, {
                    text: "取消", cls: 'l-dialog-btn-no', onclick:function(){
                        $.ligerDialog.hide();
                    }
                }
            ],
            title : '催收记录',
            target: $("#div_rsk_type")
        });

        //添加默认本人 start
        cstTypCd = '${rskCommRecVO.cstBscInfoVO.cstTypCd}';
        if(cstTypCd == '1'){
            $("#winlkMan").val('${rskCommRecVO.cstNm}');
            $("#winlkManRl").text("(本人)");
            $("#winLkPhone").val('${rskCommRecVO.cstNpBscInfoVO.mp1}');
            $("#winLkAddr").val("${rskCommRecVO.cstNpBscInfoVO.workAddr}");//联系地址

            $("#winRlNm").val('${rskCommRecVO.cstNm}');//关联人姓名（面谈人）
            $("#winRlTypCd").val('本人');//与客户的关系
            $("#winRlMp").val("${rskCommRecVO.cstNpBscInfoVO.mp1}");//关联人电话

        }
        //添加默认本人 end

        ligerRskForm = $("#div_rsk_type_form").ligerForm({
            validate: true
        });

        clearUploadResultParams();
    }

    function assertChecked(name,content){
        var val = $("input[name='"+name+"']:checked").val();
        if(StringUtils.isEmpty(val)){
            $.ligerDialog.SQalert({content: content+"为必填项", SQ_type: "warning"});
            return false;
        }
        return true;
    }
    function assertNotEmpty(name,content){
        var val = $("input[name='"+name+"']").val();
        if(StringUtils.isEmpty(val)){
            $.ligerDialog.SQalert({content: content+"为必填项", SQ_type: "warning"});
            return false;
        }
        return true;
    }
    // 表单校验
    function addValidation(){
        //催收方式必填
        var winCollectWayCd = $("input[name='winCollectWayCd']:checked").val();

        //C卡风险等级
        var cCardRiskLevel=$("#cCardRiskLevel").val();
        if(!cCardRiskLevel){
            $.ligerDialog.SQalert({content: "C卡风险等级为必填项", SQ_type: "warning"});
            return false;
        }
        //催收员给定风险等级
        var collectRiskLevel=$("#collectRiskLevel").val();
        if(!collectRiskLevel){
            $.ligerDialog.SQalert({content: "催收员给定风险等级为必填项", SQ_type: "warning"});
            return false;
        }
        //风险判定差异原因
        var levelDifRsn=$("#levelDifRsn").val();
        if((cCardRiskLevel!=collectRiskLevel) && !levelDifRsn && levelDifRsn != ""){
            $.ligerDialog.SQalert({content: "催收员给定风险与C卡风险等级不同时，风险判定差异原因为必填项", SQ_type: "warning"});
            return false;
        }
        if(!assertChecked("winCollectWayCd","催收方式")){
            return false;
        }
        if(!assertChecked("winOvdReasonCd","逾期原因")){
            return false;
        }

        // 催收方式为电话催收  接通状态为必填
        if(winCollectWayCd=="1"){
            if(!assertChecked("winCntStsCd","接通状态")){
                return false;
            }
            var winCntStsCd = $("input[name='winCntStsCd']:checked").val();
            // 接通状态为 接通 催收结果为必填
            if(winCntStsCd=="8"){
                if(!assertChecked("winCollectRstCd","催收结果")){
                    return false;
                }
            }

        }
        // 催收方式为信函催收 信函类型 发送结果 信函邮寄方式为必填
        if(winCollectWayCd=="2"){
            if(!assertChecked("winLetterTypCd","信函类型")){
                return false;
            }
            if(!assertChecked("letterSendRes","信函发送结果")){
                return false;
            }
            var letterSendWay = $("input[name='letterSendWay']:checked").val();
            if(!assertChecked("letterSendWay","信函邮寄方式")){
                return false;
            }
            // 寄送方式为邮寄 邮寄单号为必填
            if(letterSendWay=="2"){
                if(!assertNotEmpty("expressNo","邮寄单号")){
                    return false;
                }
            }
        }
        // 催收方式为外访催收 外访结果  地址真实性为必填
        if(winCollectWayCd=="3"){
            if(!assertChecked("isRealAdress","地址真实性")){
                return false;
            }
            if(!assertChecked("winVisitRstCd","外访结果")){
                return false;
            }
        }
        return true;
    }
    //执行保存 start
    function doAdd(){
        ligerRskForm = liger.get("div_rsk_type_form");
        // 自定义表单校验
        if(!addValidation()){
            return;
        }

        if (!ligerRskForm.valid()) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var data = ligerRskForm.getData();
        var lkTypCd = $("#winlkManRl").text();
        data["lKTypCd"] = lkTypCd;//联系人与客户的关系
        var docArray = JSON.stringify(getUploadResultParams());

        //赋值附件
        data["docArray"] = docArray;

        $.ligerDialog.hide();
        var _url;
        _url = '<%=path%>/risknew/rskCommRecNew/add.do';
        var wait_dialog;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: _url,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                    grid.reload();
                } else {
                    $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                }
            }
        });
    }
    // 事件注册
    function eventRegiste(){
        // 催收方式
        $("input[name='winCollectWayCd']").click(onWinCollectWayCdClick);
        //逾期原因
        $("input[name='winOvdReasonCd']").change(onwinOvdReasonCdClick);
        // 接通状态
        $("input[name='winCntStsCd']").click(onWinCntStsCdClick);
        // 是否真实地址
        $("input[name='isRealAdress']").click(onIsRealAdressClick);
        // 信函发送方式
        $("input[name='letterSendWay']").click(onLetterSendWayClick);

    }
    /**
     *  点击催收方式
     */
    var preCollectWayCd = "";// 前一个催收方式选中的值
    function onWinCollectWayCdClick(){
        var radioVal = $(this).val()
        if(preCollectWayCd!="" && preCollectWayCd != radioVal){
            refresh();
        }
        if(preCollectWayCd!=radioVal){
            preCollectWayCd=radioVal;
        }
        $("#winCntStsCdDiv").hide();
        $("#letterDiv").hide()
        $("#winRlNmDiv").hide()
        if(radioVal=="1"){ //电话催收
            // 接通状态
            $("#winCntStsCdDiv").show();
        }else if(radioVal =="2"){//信函催收
            $("#letterDiv").show()
            $("#winCollectRstCdDiv").hide()
        }else if(radioVal =="3"){//外访催收
            $("#winRlNmDiv").show()
            $("#winCollectRstCdDiv").hide()
        }
    }
    /**
     * 选邮寄时  快递单号必填
     */
    function onLetterSendWayClick(){
        var val = $(this).val();
        var form = liger.get("div_rsk_type_form");
        if(val == "2"){
            $("#expressNoDiv").show();
        }else{
            $("#expressNoDiv").hide();
        }
    }

    // 点击是否真实地址
    function onIsRealAdressClick(){
        var val = $(this).val();
        $("#realAdressDiv").hide();
        if(val=="2"){ //真实
            $("#realAdressDiv").show();
        }
    }
    // 接通方式选已接通时，需要显示催收结果
    function onWinCntStsCdClick(){
        var radioVal = $(this).val()
        if(radioVal=="8"){//接通
            $("#winCollectRstCdDiv").show();
        }else{
            $("#winCollectRstCdDiv").hide();
        }
    }
    // 点击催收方式事件处理

    //执行保存 end
    var ovdReasonList = ${ovdReasonDTOS};
    var participantList = ${participantList};
    /**
     * 逾期原因点击事件，
     * 根据选择的原因赋值风险级别，若有多个原因，则取他们当中最高的风险级别
     */
    function onwinOvdReasonCdClick(){
        var checkedValueList = new Array();
        var checkedList = $("input[name='winOvdReasonCd']:checked").each(function(index,item){
            checkedValueList.push($(this).val())
        });
        if(checkedValueList.length>0){
            var maxRiskLevel = 0;
            for(var val of checkedValueList){
                for(var dto of ovdReasonList){
                    if(val == dto.code){
                        if(dto.codeAttr1 > maxRiskLevel){
                            maxRiskLevel = dto.codeAttr1
                        }
                    }
                }
            }
            $("#winPayWnCd").ligerComboBox().setValue(maxRiskLevel);
        }else{
            $("#winPayWnCd").ligerComboBox().setValue("");
        }
    }
    //初始化弹出层form数据 start
    function initFormData(){

        //催收方式
        var collectWayCdList = ${collectWayCdList};
        $("#winCollectWayCd").ligerRadioList({
            data:collectWayCdList,
            textField:"value",
            valueField:"key"
        });

        // 接通状态
        var cntStsCdList = ${cntStsCdList};
        $("#winCntStsCd").ligerRadioList({
            data:cntStsCdList,
            textField:"value",
            valueField:"key"
        });

        //催收结果
        var collectRstCdList = ${collectRstCdList};
        $("#winCollectRstCd").ligerRadioList({
            data:collectRstCdList,
            textField:"value",
            valueField:"key",

        });
        //信函类型
        var letterTypCdList = ${letterTypCdList};
        $("#winLetterTypCd").ligerRadioList({
            data:letterTypCdList,
            textField:"value",
            valueField:"key"

        });
        // 信函发送结果
        var letterSendResList = ${letterSendResList};
        $("#letterSendRes").ligerRadioList({
            data:letterSendResList,
            textField:"value",
            valueField:"key"

        });
        // 信函发送方式
        var letterSendWayList = ${letterSendWayList};
        $("#letterSendWay").ligerRadioList({
            data:letterSendWayList,
            textField:"value",
            valueField:"key"
        });
        //外访结果
        var visitRstCdList = ${visitRstCdList};
        $("#winVisitRstCd").ligerRadioList({
            data:visitRstCdList,
            textField:"value",
            valueField:"key"
        });
        // 地址真实性
        var isRealAdressList = ${isRealAdressList}
        $("#isRealAdress").ligerRadioList({
            data:isRealAdressList,
            textField:"value",
            valueField:"key"
        });

        $("#minOverdueDate").val(DateUtils.formatDate(new Date(${minOverdueDate}),DateUtils.YYYY_MM_DDHHMMSS));
        
        
        var _payWnCdList=${payWnCdList};
        
        $("#winPayWnCd").ligerComboBox({
            data:_payWnCdList,
    		valueField: 'key',
    		textField: 'value',
    		width:150
    	});
        liger.get("winPayWnCd").setDisabled();
        var initpayData=[]; 
         $.each(${payWnCdList},function (i,o) {
            var item={};
            item.key=o.key;
            item.value=o.value;
            initpayData.push(item);
        });


        // 逾期原因 复选框
         $("#winOvdReasonCd").ligerCheckBoxList({
     		valueField: 'code',
     		textField: 'codeNm',
     		data:ovdReasonList
     	});
        // 逾期原因 复选框
        $("#participantDiv").ligerCheckBoxList({
            valueField: 'code',
            textField: 'codeNm',
            data:participantList
        });
    }
    //初始化弹出层form数据 end

    //跳转到查看页面
    function toViewPageInfo(_id) {
        $.ligerDialog.SQopen({
            cls: 'noBorder_Dialog',
            width: 800,
            //top: 100,
            height:500,
            //url: '<%=path%>/risk/rskCommRec/todownloadPage.do?id=' + _id,
            url: '<%=path%>/risknew/rskCommRecNew/toModifyPage.do?id=' + _id,
            buttons: [
                {
                    text: "取消", cls: 'l-dialog-btn-no', onclick:function(){
                        $.ligerDialog.hide();
                    }
                }
            ],
            title : '催收记录'
            //target: $("#div_rsk_type_view")
        });
    }

    //跳转到新增社会关系页面
    function toCustNpList(cstId,lkType) {
        //parent.mainApp.f_addTab('tab_custNpList'+cstId,'联系人','<%=path%>/risknew/rskCommRecNew/toCustNpList.do?lkType=1&&cstId='+cstId,callback);
        if(lkType == '1'){
            Add_navTab('tab_custNpList_add'+cstId,'新增联系人','<%=path%>/risknew/rskCommRecNew/toCustNpList.do?lkType=1&&cstId='+cstId);
        }else if(lkType == '2'){
            Add_navTab('tab_custNpList_select'+cstId,'选择联系人','<%=path%>/risknew/rskCommRecNew/toCustNpList.do?lkType=2&&cstId='+cstId,setDataByChild);
        }else if(lkType == '3'){
            Add_navTab('tab_custNpList_rlnm'+cstId,'选择面谈人','<%=path%>/risknew/rskCommRecNew/toCustNpList.do?lkType=3&&cstId='+cstId,setDataByChild);
        }
    }

    // winlkMan  选择联系人回调函数
    function setDataByChild(rlNm,mp,homeAddr,rlTypCdNm,lkType){
        if(lkType == '2'){
            $("#winlkMan").val(rlNm);
            $("#winLkPhone").val(mp);
            $("#winLkAddr").val(homeAddr);
            $("#winlkManRl").text("(" + rlTypCdNm + ")");
        }else if(lkType == '3'){
            $("#winRlNm").val(rlNm);
            $("#winRlMp").val(mp);
            $("#winRlTypCd").val(rlTypCdNm);
        }

    }
</script>

</body>
</html>
